<template>
    <el-upload class="upload-demo" drag action="https://www.google.com" multiple :before-upload="func">
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip" slot="tip">暂时只能上传jpg/png文件</div>
    </el-upload>
</template>

<script>
    export default {
        name: "Upload",
        data:function(){
            return{
            }
        },
        props:{
        },
        methods:{
            func:function (file) {
                let reader = new FileReader();
                reader.readAsDataURL(file)
                var that = this
                reader.onload = function (e) {
                    let result = e.target.result
                    // var image = new Image()
                    // image.src = result
                    // image.onload = function () {
                    //     var canvas = this.canvas
                    //     if(image.width>image.height){
                    //         image.height = (canvas.width/image.width)*image.height
                    //         image.width = canvas.width
                    //    }else{
                    //         image.width = (canvas.height/image.height)*image.width
                    //         image.height = canvas.height
                    //     }
                   that.$emit('upload-img',result)
                }
            }
        }
    }
</script>

<style scoped>

</style>









